<!DOCTYPE html>
<html>
<head>
    <title>找攻略</title>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css"/>
    <link rel="stylesheet" href="/css/travel.css"/>
    <link rel="stylesheet" href="/css/strategy.css"/>
    <link rel="stylesheet" href="/js/plugins/dialog/dialog.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap/js/bootstrap.min.js"></script>
    <script src="/js/plugins/dialog/dialog.min.js"></script>
    <script src="/js/plugins/jrender/jrender.js"></script>
    <script src="/js/common.js"></script>
    <script>
        var tabs = []; //记录当前标签页信息(当前页/总页数等)
        var currentTab = 0; //当前查看的标签页信息
        var user = JSON.parse(sessionStorage.getItem("user"));
        var travels = []; //游记数组

        function travel(){
            //查询游记收藏
            $.get("/travelCollect/query/" + user.id,{pageSize:3}, function (data) {
                console.log(data);
                travels = data.list;
                tabs[0] = {id: 1, currentPage: 1, pages: data.pages,Collect:"travelCollect"};
                $("#pills-1").renderValues(data, {
                    travelCollect: function (ele, value) {
                        ele.href = "/travelContent.html?id=" + value;
                    }
                });
            })
        }
        function strategy(){
            $.get("/strategycollect/query/" + user.id,{pageSize:3}, function (data) {
                console.log(data);
                travels = data.list;
                tabs[1] = {id: 2, currentPage: 1, pages: data.pages,Collect:"strategycollect"};
                $("#pills-2").renderValues(data, {
                    strategyCollect: function (ele, value) {
                        ele.href = "/strategyCatalogs.html?strategyId=" + value;
                    }
                });
            })
        }
        $(function () {
            travel();

            $("#p1").click(function () {
                currentTab = 0;
                travels= [];
                travel();
            })
            $("#p2").click(function () {
                currentTab = 1;
                travels= [];
                strategy();
            })

            //设置窗口的滚到事件,用于翻页
            $(window).scroll(function () {
                if (isEnd()) {
                    console.log(tabs[currentTab].currentPage);
                    console.log(tabs[currentTab].pages);
                    if (tabs[currentTab].currentPage < tabs[currentTab].pages) {
                        tabs[currentTab].currentPage++;
                        $.get("/"+tabs[currentTab].Collect+"/query/" + user.id, {currentPage: tabs[currentTab].currentPage,pageSize:3}, function (data) {
                            $.merge(travels, data.list);
                            $("#pills-" + tabs[currentTab].id).renderValues({list: travels}, {
                                    travelCollect: function (ele, value) {
                                    ele.href = "/travelContent.html?id=" + value;
                                    },
                                    strategyCollect: function (ele, value) {
                                    ele.href = "/strategyCatalogs.html?strategyId=" + value;
                                }

                            });
                        })
                    } else {
                        $(document).dialog({
                            type : "notice",
                            infoText: "已经到底了呀(/▽＼)",
                            autoClose: 1500,
                            position: "bottom"
                        });
                    }
                }
            })
        })

    </script>
</head>

<body>
<div class="search-head">
    <div class="row nav-search">
        <div class="col-2">
            <a href="../index.html">
                <span><i class="fa fa-chevron-left fa-2x"></i></span>
            </a>
        </div>
        <div class="col-10">
            <div class="input-group-sm search">
                <input class="form-control searchBtn" placeholder="找攻略">
            </div>
        </div>
    </div>
</div>

<ul class="nav nav-pills nav-justified border border-left-0 border-top-0 border-right-0" id="pills-tab" role="tablist">
    <!--选项卡-->
    <li class="nav-item">
        <a class="nav-link active show" data-toggle="pill" href="#pills-1" id="p1">
            <span style="font-weight: bold;">游记收藏</span>
        </a>
    </li>
    <li class="nav-item">
        <a class="nav-link show" data-toggle="pill" href="#pills-2" id="p2">
            <span style="font-weight: bold;">攻略收藏</span>
        </a>
    </li>

</ul>
<div class="container tab-content" id="pills-tabContent">
    <div class="tab-pane fade show active" id="pills-1">
        <div id="allTravels" render-loop="list">

            <div class="row detail">
                <div class="col">
                    <a href="travelContent.html" render-key="list.travel.id" render-fun="travelCollect">
                        <h4 render-html="list.travel.title"></h4>
                    </a>
                    <p>
                        <a href="userProfiles.html">
                            <img class="rounded-circle head-img" render-src="list.user.headImgUrl">
                            <span render-html="list.user.nickName"></span> </a> 在
                        <span class="addr" render-html="list.place"></span>

                    </p>
                    <p>
                        <i class="fa fa-eye fa-fw"></i>
                        <span>1亿+</span>
                        <i class="fa fa-commenting fa-fw"></i>
                        <span>1亿+</span>
                    </p>
                </div>
                <div class="col bigimg">
                    <a href="travelContent.html" render-key="list.travel.id" render-fun="travelCollect">
                        <img render-src="list.travel.coverUrl">
                    </a>
                </div>
            </div>
        </div>
    </div>

    <div class="comment tab-pane fade " id="pills-2">
        <div render-loop="list">
            <div style="margin-bottom: 20px">
                <a href="#" render-key="list.strategy.id" render-fun="strategyCollect">
                    <div class="row news-detail">
                        <div class="col-5">
                            <img render-src="list.strategy.coverUrl">
                        </div>
                        <div class="col-7">
                            <h4 render-html="list.strategy.title"></h4>
                            <p render-html="list.strategy.subTitle"></p>
                        </div>
                    </div>
                </a>
                <hr>
            </div>
        </div>

    </div>
    <div class="tab-pane fade" id="pills-contact">.3333..</div>
</div>
<!-- 选项卡对应的内容
<div class="tab-content" id="pills-tabContent">
    &lt;!&ndash; 标签页的内容 &ndash;&gt;
    <div class="tab-pane fade active show" id="pills-top">
        <div class="container commend">
            <a href="../travelContent.html" render-key="travelId" render-fun="handle">
                <img render-src="coverUrl">
                <p render-html="title"></p>
            </a>
        </div>
        <hr>
        <div class="container strategyCommend">
            <h6>推荐</h6>
            <div class="row hot" render-loop="list">
                &lt;!&ndash; 大攻略推荐模板 &ndash;&gt;
                <div class="col-4">
                    <a href="../strategyCatalogs.html" render-key="list.id" render-fun="handle">
                        <img render-src="list.coverUrl">
                        <p render-html="list.title"></p>
                    </a>
                </div>

            </div>
        </div>
    </div>

</div>-->
</body>
</html>